﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:Resources="clr-namespace:GasyTek.Lakana.WPF.Resources"
                    xmlns:ui="clr-namespace:GasyTek.Lakana.WPF.Controls">

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></BooleanToVisibilityConverter>

    <!-- MessageBoxControl styles -->

    <Style x:Key="{x:Type ui:MessageBoxControl}"
           TargetType="{x:Type ui:MessageBoxControl}">
        <Setter Property="BorderBrush"
                Value="White" />
        <Setter Property="BorderThickness"
                Value="2" />
        <Setter Property="Background"
                Value="White" />
        <Setter Property="Background"
                Value="White" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ui:MessageBoxControl}">
                    <Border x:Name="outerBorder"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="2"
                            Padding="10"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Width="400"
                            Height="180">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <Image x:Name="iconContainer"
                                   RenderOptions.BitmapScalingMode="HighQuality"
                                   Width="64"
                                   Height="64"
                                   Margin="10"
                                   VerticalAlignment="Center" />

                            <TextBlock Grid.Column="1"
                                       Text="{TemplateBinding Message}"
                                       FontSize="16"
                                       VerticalAlignment="Center"
                                       TextWrapping="Wrap" />

                            <Border Grid.Row="1"
                                    Grid.ColumnSpan="2"
                                    HorizontalAlignment="Center">
                                <StackPanel Orientation="Horizontal">
                                    <Button x:Name="PART_Yes"
                                            Content="{x:Static Resources:Labels.Yes}"
                                            Visibility="Collapsed"
                                            Width="100"
                                            Margin="3" />
                                    <Button x:Name="PART_No"
                                            Content="{x:Static Resources:Labels.No}"
                                            Visibility="Collapsed"
                                            Width="100"
                                            Margin="3" />
                                    <Button x:Name="PART_Ok"
                                            Content="{x:Static Resources:Labels.Ok}"
                                            Visibility="Collapsed"
                                            Width="100"
                                            Margin="3" />
                                    <Button x:Name="PART_Cancel"
                                            Content="{x:Static Resources:Labels.Cancel}"
                                            Visibility="Collapsed"
                                            Width="100"
                                            Margin="3" />
                                </StackPanel>
                            </Border>

                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="MessageBoxImage"
                                 Value="Information">
                            <Setter TargetName="iconContainer"
                                    Property="Source"
                                    Value="pack://application:,,,/GasyTek.Lakana.WPF;component/Resources/Images/info.png" />
                        </Trigger>
                        <Trigger Property="MessageBoxImage"
                                 Value="Question">
                            <Setter TargetName="iconContainer"
                                    Property="Source"
                                    Value="pack://application:,,,/GasyTek.Lakana.WPF;component/Resources/Images/question.png" />
                        </Trigger>
                        <Trigger Property="MessageBoxImage"
                                 Value="Error">
                            <Setter TargetName="iconContainer"
                                    Property="Source"
                                    Value="pack://application:,,,/GasyTek.Lakana.WPF;component/Resources/Images/error.png" />
                        </Trigger>
                        <Trigger Property="MessageBoxImage"
                                 Value="Warning">
                            <Setter TargetName="iconContainer"
                                    Property="Source"
                                    Value="pack://application:,,,/GasyTek.Lakana.WPF;component/Resources/Images/warning.png" />
                        </Trigger>

                        <Trigger Property="MessageBoxButton"
                                 Value="OK">
                            <Setter TargetName="PART_Ok"
                                    Property="Visibility"
                                    Value="Visible" />
                        </Trigger>
                        <Trigger Property="MessageBoxButton"
                                 Value="OKCancel">
                            <Setter TargetName="PART_Ok"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="PART_Cancel"
                                    Property="Visibility"
                                    Value="Visible" />
                        </Trigger>
                        <Trigger Property="MessageBoxButton"
                                 Value="YesNo">
                            <Setter TargetName="PART_Yes"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="PART_No"
                                    Property="Visibility"
                                    Value="Visible" />
                        </Trigger>
                        <Trigger Property="MessageBoxButton"
                                 Value="YesNoCancel">
                            <Setter TargetName="PART_Yes"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="PART_No"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="PART_Cancel"
                                    Property="Visibility"
                                    Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ModalHostControl styles -->

    <Style x:Key="{x:Type ui:ModalHostControl}"
           TargetType="{x:Type ui:ModalHostControl}">
        <Setter Property="Background">
            <Setter.Value>
                <SolidColorBrush Color="Black"
                                 Opacity="0.5" />
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ui:ModalHostControl}">
                    <Canvas x:Name="PART_Panel"
                            Background="{TemplateBinding Background}">
                        <Border x:Name="PART_Draggable"
                                Background="Transparent"
                                VerticalAlignment="Center">
                            <ContentPresenter ContentSource="ModalContent" />
                        </Border>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ShutdownApplicationControl styles -->

    <Style x:Key="{x:Type ui:ShutdownApplicationControlItem}"
           TargetType="ui:ShutdownApplicationControlItem">
        <Setter Property="ViewKey"
                Value="{Binding ViewKey, Mode=OneWay}" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="BorderBrush"
                Value="LightGray" />
        <Setter Property="Cursor"
                Value="Hand" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ui:ShutdownApplicationControlItem">
                    <Border x:Name="outerBorder"
                            Margin="3"
                            Padding="3"
                            CornerRadius="2"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}">
                        <ContentPresenter ContentSource="Content"
                                          ContentTemplate="{TemplateBinding ContentTemplate}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True"
                                 SourceName="outerBorder">
                            <Setter Property="Background"
                                    TargetName="outerBorder">
                                <Setter.Value>
                                    <SolidColorBrush Color="LightBlue"
                                                     Opacity="0.5" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid>
                        <Grid.Resources>
                            <sys:String x:Key="noIcon">
                                pack://application:,,,/GasyTek.Lakana.WPF;component/Resources/Images/runningTask.png
                            </sys:String>
                        </Grid.Resources>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Image Source="{Binding UIMetadata.Icon, TargetNullValue={StaticResource noIcon}, FallbackValue={StaticResource noIcon}}"
                               Width="32"
                               Height="32" />
                        <TextBlock Grid.Column="1"
                                   Text="{Binding UIMetadata.Label}"
                                   Margin="5,0,0,0"
                                   VerticalAlignment="Center"
                                   TextTrimming="CharacterEllipsis" />
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type ui:ShutdownApplicationControl}"
           TargetType="ui:ShutdownApplicationControl">
        <Setter Property="BorderBrush"
                Value="White" />
        <Setter Property="BorderThickness"
                Value="2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ui:ShutdownApplicationControl">
                    <Border x:Name="outerBorder"
                            Width="400"
                            Height="400"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="4">
                        <Grid Margin="15">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <TextBlock Text="{x:Static Resources:Labels.RunningTasks}"
                                       FontSize="22"
                                       FontWeight="SemiBold" />
                            <TextBlock Grid.Row="1"
                                       Text="{x:Static Resources:Labels.ClickTaskToCloseItGracefully}"
                                       Margin="20,10,20,10"
                                       TextWrapping="Wrap" />

                            <ScrollViewer Grid.Row="2"
                                          HorizontalScrollBarVisibility="Hidden"
                                          VerticalScrollBarVisibility="Auto">
                                <ItemsPresenter />
                            </ScrollViewer>

                            <Grid Grid.Row="3"
                                  Margin="0,10,0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Button x:Name="PART_ExitApplication"
                                        Content="{x:Static Resources:Labels.ExitApplication}" />
                                <Button Grid.Column="1"
                                        x:Name="PART_Cancel"
                                        Content="{x:Static Resources:Labels.Cancel}"
                                        Width="100"
                                        Margin="10,0,0,0" />
                            </Grid>

                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>